package com.ruoyi.hospital.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hospital.domain.HosAssign;
import com.ruoyi.hospital.service.IHosAssignService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 床位分配信息Controller
 * 
 * @author ruoyi
 * @date 2024-01-06
 */
@RestController
@RequestMapping("/hospital/assign")
public class HosAssignController extends BaseController
{
    @Autowired
    private IHosAssignService hosAssignService;

    /**
     * 查询床位分配信息列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:assign:list')")
    @GetMapping("/list")
    public TableDataInfo list(HosAssign hosAssign)
    {
        startPage();
        List<HosAssign> list = hosAssignService.selectHosAssignList(hosAssign);
        return getDataTable(list);
    }

    /**
     * 导出床位分配信息列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:assign:export')")
    @Log(title = "床位分配信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HosAssign hosAssign)
    {
        List<HosAssign> list = hosAssignService.selectHosAssignList(hosAssign);
        ExcelUtil<HosAssign> util = new ExcelUtil<HosAssign>(HosAssign.class);
        util.exportExcel(response, list, "床位分配信息数据");
    }

    /**
     * 获取床位分配信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:assign:query')")
    @GetMapping(value = "/{assignId}")
    public AjaxResult getInfo(@PathVariable("assignId") Long assignId)
    {
        return success(hosAssignService.selectHosAssignByAssignId(assignId));
    }

    /**
     * 新增床位分配信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:assign:add')")
    @Log(title = "床位分配信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HosAssign hosAssign)
    {
        return toAjax(hosAssignService.insertHosAssign(hosAssign));
    }

    /**
     * 修改床位分配信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:assign:edit')")
    @Log(title = "床位分配信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HosAssign hosAssign)
    {
        return toAjax(hosAssignService.updateHosAssign(hosAssign));
    }

    /**
     * 删除床位分配信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:assign:remove')")
    @Log(title = "床位分配信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assignIds}")
    public AjaxResult remove(@PathVariable Long[] assignIds)
    {
        return toAjax(hosAssignService.deleteHosAssignByAssignIds(assignIds));
    }
}
